package domotica.scontrol.rcp.gui.view;

import org.eclipse.jface.viewers.ListViewer;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;

import domotica.scontrol.rcp.ContentProvider;

public class CopyOfOutputView implements IOutputView {
	private ListViewer viewer;
	private Display display;
	private IOutputView outputView;
	
	public CopyOfOutputView(Composite parent) {
		viewer = new ListViewer(parent);
		viewer.setContentProvider(new ContentProvider());
		display = parent.getDisplay();
		outputView = this;
	}
	
	public IOutputView getOutputView() {
		return outputView;
	}

	public void addOutput(final String msg) {
		display.asyncExec(
			new Runnable() {
				public void run(){
					viewer.setInput(msg);
				}
			}
		);
	}
	
	public void setFocus() {
		display.getFocusControl().setFocus();
	}
	
	@Override
	public void dispose() {
	}
}
